package jia.game.combat;

import java.awt.*;
import java.util.LinkedList;

public class CombatEventProcessor{
	private LinkedList<AWTEvent> eventList;
	private CombatEventProcessable handler;

	public CombatEventProcessor(CombatEventProcessable handler){
		eventList = new LinkedList<AWTEvent>();
		this.handler = handler;
	}

	/**
	 * @param event
	 */
	public void addEvent(AWTEvent event){
		synchronized(eventList) {
			eventList.add(event);
		}
	}

	/**
	 *
	 */
	public void processEventList(){
		AWTEvent event;
		while(eventList.size() > 0) {
			synchronized(eventList) {
				event = eventList.removeFirst();
			}
			handler.handleEvent(event);
		}
	}
}